# -*- coding:utf8 -*-

import time
import json
import codecs

class WeatherPipeline(object):
    print '--------------------json--------------------'
    def process_item(self, item, spider):
        today = time.strftime('%Y%m%d', time.localtime())
        filename = today + '.json'
        try:
            with codecs.open(filename, 'a', encoding='utf8') as fp:
                line = json.dumps(dict(item), ensure_ascii=False) + '\n'
                fp.write(line)
        except:
            print 'open file error'
        print '--------------------json--end------------------'

        return item
